define([], function() {    
    function SinglePageViewLayout(docView, pdfDoc){
        _docView = docView;         
        _pdfDoc = pdfDoc;     
        _curPDFPageView = null;       
        _createPageViewFunc = null;

        this.createPDFPageView = function(callback) {
            if  (typeof callback != "function") return;
            if ( _pdfDoc.pdfPages.length === 0) return;
            _createPageViewFunc = callback;

            this.gotoPage(0);                    
        };


        this.gotoPage = function(pageIndex) {
            if (!_createPageViewFunc) return;
            if (pageIndex < 0 || pageIndex >= _pdfDoc.pdfPages.length) return;

            if (_curPDFPageView){
                if (parseInt(_curPDFPageView.attr("pageIndex")) == pageIndex) return;
                _curPDFPageView.scope().$destroy();
                _curPDFPageView.remove();               
            }
            _curPDFPageView  = _createPageViewFunc(_pdfDoc.pdfPages[pageIndex]);
            this.scrollApi.getContentPane().append(_curPDFPageView);            
        };
    } 
    return SinglePageViewLayout;
});